﻿// Sort 3 real values in descending order using nested if statements.

using System;

class SortDescOrder3Numbers
{
    static void Main()
    {
        Console.Write("Enter first number: ");
        string numberStr1 = Console.ReadLine();
        double number1;
        while (!double.TryParse(numberStr1, out number1))
        {
            Console.Write("Invalid input! Please, enter your first number again : ");
            numberStr1 = Console.ReadLine();
        }

        Console.Write("Enter second number : ");
        string numberStr2 = Console.ReadLine();
        double number2;
        while (!double.TryParse(numberStr2, out number2))
        {
            Console.Write("Invalid input! Please, enter your second number again : ");
            numberStr2 = Console.ReadLine();
        }

        Console.Write("Enter third number : ");
        string numberStr3 = Console.ReadLine();
        double number3;
        while (!double.TryParse(numberStr3, out number3))
        {
            Console.Write("Invalid input! Please, enter your third number again : ");
            numberStr3 = Console.ReadLine();
        }

        double temp = 0;

        // get the smallest number of all 3 numbers and put it in number1
        if (number1 < number2)
        {
            temp = number2;
            number2 = number1;
            number1 = temp;
        }

        if (number1 < number3)
        {
            temp = number3;
            number3 = number1;
            number1 = temp;
        }

        if (number2 < number3)
        {
            temp = number3;
            number3 = number2;
            number2 = temp;
        }

        Console.WriteLine("Descending sorted nunbers : {0}, {1}, {2}", number1, number2, number3);
    }
}
